gtk-query-settings \
gtk-launch
-gtk_query_immodules_3_0_SOURCES = queryimmodules.c
+gtk_query_immodules_3_0_SOURCES = queryimmodules.c gtkutils.c
gtk_query_immodules_3_0_LDADD = \
libgtk-3.la \
$(top_builddir)/gdk/libgdk-3.la \
#include "gtkprivate.h"
#include "gtkmodulesprivate.h"
#include "gtkintl.h"
+#include "gtkutilsprivate.h"
#include <gmodule.h>
g_free (default_dir);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- result = pango_split_file_list (module_path);
-G_GNUC_END_IGNORE_DEPRECATIONS
+ result = gtk_split_file_list (module_path);
g_free (module_path);
return result;
GTK_NOTE (MODULES, g_message ("Loading module list: %s", module_str));
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- module_names = pango_split_file_list (module_str);
-G_GNUC_END_IGNORE_DEPRECATIONS
- for (i = 0; module_names[i]; i++)
+ module_names = gtk_split_file_list (module_str);
+ for (i = 0; module_names[i]; i++)
module_list = load_module (module_list, module_names[i]);
module_list = g_slist_reverse (module_list);
return (n_read > 0) ? lines : 0;
}
+
+char *
+gtk_trim_string (const char *str)
+{
+ int len;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ while (*str && g_ascii_isspace (*str))
+ str++;
+
+ len = strlen (str);
+ while (len > 0 && g_ascii_isspace (str[len - 1]))
+ len--;
+
+ return g_strndup (str, len);
+}
+
+char **
+gtk_split_file_list (const char *str)
+{
+ int i = 0;
+ int j;
+ char **files;
+
+ files = g_strsplit (str, G_SEARCHPATH_SEPARATOR_S, -1);
+
+ while (files[i])
+ {
+ char *file = gtk_trim_string (files[i]);
+
+ /* If the resulting file is empty, skip it */
+ if (file[0] == '\0')
+ {
+ g_free (file);
+ g_free (files[i]);
+
+ for (j = i + 1; files[j]; j++)
+ files[j - 1] = files[j];
+
+ files[j - 1] = NULL;
+
+ continue;
+ }
+
+#ifndef G_OS_WIN32
+ /* '~' is a quite normal and common character in file names on
+ * Windows, especially in the 8.3 versions of long file names, which
+ * still occur now and then. Also, few Windows user are aware of the
+ * Unix shell convention that '~' stands for the home directory,
+ * even if they happen to have a home directory.
+ */
+ if (file[0] == '~' && file[1] == G_DIR_SEPARATOR)
+ {
+ char *tmp = g_strconcat (g_get_home_dir(), file + 1, NULL);
+ g_free (file);
+ file = tmp;
+ }
+ else if (file[0] == '~' && file[1] == '\0')
+ {
+ g_free (file);
+ file = g_strdup (g_get_home_dir ());
+ }
+#endif
+
+ g_free (files[i]);
+ files[i] = file;
+
+ i++;
+ }
+
+ return files;
+}
gboolean gtk_skip_space (const char **pos);
gint gtk_read_line (FILE *stream,
GString *str);
+char * gtk_trim_string (const char *str);
+char ** gtk_split_file_list (const char *str);
G_END_DECLS
#include "gtk/gtkimcontextinfo.h"
#include "gtk/gtkversion.h"
+#include "gtk/gtkutilsprivate.h"
#include "gtk/deprecated/gtkrc.h"
g_string_append_printf (contents, "# ModulesPath = %s\n#\n", path);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- dirs = pango_split_file_list (path);
-G_GNUC_END_IGNORE_DEPRECATIONS
+ dirs = gtk_split_file_list (path);
dirs_done = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
for (i = 0; dirs[i]; i++)